<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

</body>
</html>
<script>
    var url = "http://www.itcast.cn?name=andy";
    console.log(encodeURIComponent(url));  // 编码
    var afterUrl = encodeURIComponent(url);
    console.log(decodeURIComponent(afterUrl));  // 解码
</script>